package com.chainyoung.trademarket.mvp.model;

import com.chainyoung.common.bean.UserInfo;
import com.chainyoung.common.integration.IRepositoryManager;
import com.chainyoung.common.mvp.BaseModel;
import com.chainyoung.common.utils.RxUtils;
import com.chainyoung.component_tmmarket.api.MarketService;
import com.chainyoung.trademarket.api.MainService;
import com.chainyoung.trademarket.di.module.FindData;
import com.chainyoung.trademarket.entity.IndexApp;
import com.chainyoung.trademarket.entity.IndexData;
import com.chainyoung.trademarket.mvp.contract.FindContract;
import com.chainyoung.trademarket.mvp.contract.IndexContract;

import java.util.List;
import java.util.TreeMap;

import javax.inject.Inject;

import io.reactivex.Flowable;

public class IndexModel extends BaseModel implements IndexContract.Model {

    @Inject
    public IndexModel(IRepositoryManager repositoryManager) {
        super(repositoryManager);
    }


    @Override
    public Flowable<IndexData> getIndexApps(TreeMap<String, Object> map) {
        return mRepositoryManager.obtainRetrofitService(MainService.class)
                .getIndexApps(map)
                //.compose(RxUtils.<BaseResponse<UserInfo>>rxSchedulerHelper())
                .compose(RxUtils.<IndexData>handleResult());
    }

    @Override
    public Flowable<UserInfo> getUserInfo(TreeMap<String, Object> map) {
        return mRepositoryManager.obtainRetrofitService(MarketService.class)
                .getUserInfo(map)
                //.compose(RxUtils.<BaseResponse<UserInfo>>rxSchedulerHelper())
                .compose(RxUtils.<UserInfo>handleResult());
    }
}
